package cat_catch_mice;

public class Car {
    String name;//名字
    double weight;//体重
    private int strength;//体力

    public int getStrength() {
        return strength;
    }

    public void setStrength(int strength) {
        if (strength>=0&&strength<=100){
            this.strength = strength;
        }else {
            this.strength=50;
            System.out.println("非法体力，默认体力为50");
        }
    }

    public void catch_mice(Mice a){
        System.out.println(name+"遇到"+a.name);
        a.run();
        int x=strength;
        int x1=a.getStrength();
        while (x>0&&x1>0){
            x--;
            x1--;
        }
        strength=x;
        a.setStrength(x1);
        if (x>a.getStrength()){
            strength=x+50;
            a.setStrength(x1);
            System.out.println(name+"抓到了"+a.name);
            System.out.println(name+"的体力为"+strength);
            System.out.println(a.name+"的体力为"+a.getStrength());
        }else if (strength<a.getStrength()){
            System.out.println(name+"体力为"+x+","+a.name+"体力为"+x1+"体力不够抓不到");
        }else {
            System.out.println("平手,歇歇在抓");
        }
    }

}
